#!/bin/bash

mysql -uroot -p123456 <<EOF
CREATE DATABASE IF NOT EXISTS work DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_general_ci;
create user if not exists 'user'@'%' identified by 'user123';
grant all on *.* to 'user'@'%';
ALTER USER 'user'@'%' IDENTIFIED WITH mysql_native_password BY 'user123';
FLUSH PRIVILEGES;
CREATE DATABASE IF NOT EXISTS flask DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
EOF
exit;

#   创建数据库work
#   创建授权客户端账号user
#   创建授权客户端密码user123
#   启动会自动执行,不需要手动创建,如果没有执行, 请执行下面命令
#   docker exec -it mysql /bin/bash /docker-entrypoint-initdb.d/mysql.sh



